<template>
	<div v-loading="loading">
		<HyForm :hyFormDefault="designUnitInfo" :hyFormConfig="hyFormConfig" :hyFormFields="hyFormFields" ref="hyFormRef" />
	</div>
</template>
<script setup lang="ts">
import HyForm from '/@/components/HyForm/index.vue';
import { defaultValue } from '../../utils/default';
const { designUnitInfo } = defaultValue();
const loading = ref(false);
const hyFormRef = ref();
const props = defineProps({
	designUnitInfoData: {
		type: Object,
		default: () => defaultValue().basicInfoDefault,
	},
	routerParams: {
		type: Object,
		default: () => {
			return {};
		},
	},
});

watch(
	[() => props.designUnitInfoData],
	(nVal, oVal) => {
		nextTick(() => {
			const basicInfoData = JSON.parse(JSON.stringify(nVal[0]));
			loading.value = true;
			hyFormRef.value.hyForm = basicInfoData;
			loading.value = false;
		});
	},
	{ deep: true }
);
//动态表单配置
const hyFormConfig = computed(() => {
	return {
		labelWidth: '150px',
		span: 8,
		offset: 0,
		type: 'submit',
	};
});
//配置基本信息表单
const hyFormFields = computed(() => {
	return {
		socialCode: {
			label: '统一社会信用代码',
			type: 'input',
			required: true,
			maxlength: 18,
		
		},
		designUnit: {
			label: '单位名称',
			type: 'input',
			required: true,
			maxlength: 50,
		
		},
	};
});
const getData = () => {
	const formData = hyFormRef.value.hyForm;
	return {
		formData,
	};
};
const designUnitInfocheck = async () => {
	return await hyFormRef.value.check(false);
};
defineExpose({ getData, designUnitInfocheck });
</script>

<style lang="scss" scoped></style>
